package com.example.first.thread;

import java.util.concurrent.locks.LockSupport;

/**
 * @Author LSQ
 * @Description park会锁住线程
 * @date 2021/9/12 21:11
 * @Version 1.0
 */

public class LearnLockSupportPark {

    public static void main(String[] args) {

        Runnable runnable = () -> {
            System.out.println("lsq");
            for (; ; ) {
                System.out.println("before park!");
                LockSupport.park();
                System.out.println("after park!");
            }
        };


        Thread thread = new Thread(runnable);
        thread.start();

        try {
            Thread.sleep(2000);
            LockSupport.unpark(thread);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }


}
